<?php





namespace app\shop\controller;



use app\admin\controller\ApiCommon;

use app\shop\model\TurnRefund as TurnRefundModel;

use Kingdee\Kingdee;

use think\facade\Db;

use think\response\Json;

class TurnRefundC extends ApiCommon
{

    /**

     * 用于判断权限

     * @permission 无限制

     * @allow 登录用户可访问

     * @author SL

     * @create 2021-06-01

     */

    public function initialize()
    {

        $action = [

            'permission' => [''],

            'allow' => ['export']

        ];

        event('CheckAuth', $action);

        $request = $this->request;

        $a       = strtolower($request->action());

        if (!in_array($a, $action['permission'])) {

            parent::initialize();

        }

    }

    public function addTurnRefund(): Json
    {
        $model = new TurnRefundModel();
        $data = $model->addTurnRefund($this->param);

        if (!$data) {

            return resultArray(['error' => $model->getError()]);

        }

        return resultArray(['data'=> [], 'error' => $model->getError()]);
    }

    public function turnPerformanceList(): Json
    {
        $header = request()->header();

        $this->param['platform'] = $header['platform'];

        $this->param['user_id'] = $this->userInfo['id'];

        $this->param['shopIds'] = $this->getCommonShopIdsCollectByUserType();

        $model = new TurnRefundModel();

        $data = $model->turnPerformanceList($this->param);
        
        return resultArray(['error' => '','data' => $data]);
    }
}